using System.Collections;
using System.Runtime.InteropServices;
using UnityEngine;
using UnityEngine.UI;
using CC_test;
using com.m3sdk.common;
using CC_Game;
using System;   
namespace test02 {
    public class C_sss002 : MonoBehaviour {
        public Text text;
        public Button S_001, S_002, S_testCrash01, S_testCrash02, S_testCrash03, S_testCrash04;  
        void Start() {
            C_LogCat.GetInstance().S_Init();
            CrashReport lastReport = CrashReport.lastReport;
            if (lastReport != null) {
                Debug.LogErrorFormat("崩溃文件存在........" + lastReport.text);
            }   
            System.AppDomain.CurrentDomain.UnhandledException += delegate (object sender, UnhandledExceptionEventArgs e) {
                try {
                    using (System.IO.FileStream fs = new System.IO.FileStream(@" c:/testme.log ",  System.IO.FileMode.Append, System.IO.FileAccess.Write)) {
                        using (System.IO.StreamWriter w = new System.IO.StreamWriter(fs, System.Text.Encoding.UTF8)) {
                            w.WriteLine(e.ExceptionObject);
                        }
                    }
                } catch {
                    Debug.LogErrorFormat("报错崩溃...错误.....................");
                }
            };       
            C_CrashHandler.GetInstance();

            cpp_log_output.S_RegisterDelegateToCpp();
            int i1 = 2;
            S_001.transform.Find("Text").GetComponent<Text>().text = "测试001";
            S_001.onClick.AddListener(delegate () {
                int dd22 = cppu3d.S_001(IntPtr.Zero, 0);
                Debug.LogErrorFormat(".......int i1 = cpp_dll.S_001(1);.............." + dd22);
            });
            S_002.onClick.AddListener(delegate () {     
                Debug.LogErrorFormat(".......int i1 = cpp_dll.S_002(1);.............." + i1);
            });
            S_testCrash01.onClick.AddListener(delegate () {      
                Debug.LogErrorFormat(".......cpp_dll.S_testCrash01(1);..............");
            });
            S_testCrash02.onClick.AddListener(delegate () {   
                Debug.LogErrorFormat(".......int i1 = cpp_dll.S_testCrash02(1);.............." + i1);
            });
            S_testCrash03.onClick.AddListener(delegate () {   
                Debug.LogErrorFormat(".......cpp_dll.S_testCrash03(1);..............");
            });
            S_testCrash04.onClick.AddListener(delegate () {  
                Debug.LogErrorFormat(".......int i1 = cpp_dll.S_testCrash04(1);............." + i1);
            });
       
        }

  
        public void Update() {
            text.text = Time.realtimeSinceStartup + "";
        }
    }

}